package com.ruoyi.parttime.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.parttime.domain.ApplyForParrtime;
import com.ruoyi.parttime.service.IApplyForParrtimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/notification")
@Api(tags = "申请通知")
public class NotificationController extends BaseController{
    @Autowired
    private IApplyForParrtimeService applyForParrtimeService;

    /**
     * 查询申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:applyfor:list')")
    @ApiOperation(value = "查询兼职申请列表")
    @GetMapping("/list")
    public TableDataInfo list(ApplyForParrtime applyForParrtime)
    {
        startPage();
        List<ApplyForParrtime> list = applyForParrtimeService.selectApplyForParrtime(applyForParrtime);
        return getDataTable(list);
    }
    /**
     * 同意或者拒绝申请
     */
    @PreAuthorize("@ss.hasPermi('system:applyfor:edit')")
    @Log(title = "操作", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "同意或者拒绝他人兼职申请")
    @PutMapping("/status")
    public AjaxResult updateApplyForStatus(@RequestBody ApplyForParrtime apply) {
        return toAjax(applyForParrtimeService.updateApplyForParrtime(apply));
    }

    /**
     * 获取申请的工作详情
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('system:publish:query')")
    @ApiOperation(value = "获取申请的工作详情")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applyForParrtimeService.selectParttimePublishById(id));
    }
}
